<template>
	<div class="container" ref="refContainer">
		<div class="doc-content">
			<div class="title">弹出层</div>
			<div class="example-title">引入方式（按需）</div>
			<code-view>
				<template slot="code-js">{{ jsCode1 }}</template>
			</code-view>
			
			
			<div class="example-title">基本用法</div>
			<div class="example-sub-title quote">
				改变show的值，可以控制popup的弹出与关闭
			</div>
			<code-view>
				<template slot="code-html">{{ htmlCode2 }}</template>
				<template slot="code-js">{{ jsCode2 }}</template>
			</code-view>
			
			<div class="example-title">弹出方向</div>
				<code-view>
					<template slot="code-html">{{ htmlCode3 }}</template>
				</code-view>
			</Demo>
			
			<div class="example-title">是否圆角</div>
			<code-view>
				<template slot="code-html">{{ htmlCode4 }}</template>
			</code-view>
			
			
			<div class="example-title">&lt;gr-popup&gt;属性</div>
			<gr-table :width="800" :tableData="propertiesExplain1" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="参数名称" width="90">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="参数说明" width="140">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="类型" width="70">
						{{rowData.type}}
					</gr-table-column>
					<gr-table-column label="可选值" width="120">
						{{rowData.optionValues}}
					</gr-table-column>
					<gr-table-column label="默认值" width="70">
						{{rowData.defaultValue}}
					</gr-table-column>
				</template>
			</gr-table>
			<div class="example-title">&lt;gr-popup&gt;事件</div>
			<gr-table :width="800" :tableData="propertiesExplain2" textAlign="left">
				<template v-slot="{rowData}">
					<gr-table-column label="事件名称" width="100">
						{{rowData.attrName}}
					</gr-table-column>
					<gr-table-column label="事件说明" width="150">
						{{rowData.introduce}}
					</gr-table-column>
					<gr-table-column label="事件回调参数" width="120">
						{{rowData.param}}
					</gr-table-column>
				</template>
			</gr-table>
		</div>
		<div class="demo-view">
			<div ref="refCellPhone" class="cellphone">
				<iframe src="demo.html#/popupdemo" frameborder="0" width="100%" height="100%"></iframe>
			</div>
		</div>
	</div>
</template>

<script>
	import Demo from '../components/Demo.vue'
	import CodeView from '../components/CodeView.vue'
	export default {
		components: {
			Demo,
			CodeView
		},
		data() {
			return {
				jsCode1: `import {Popup} from 'gabriel-ui'
Vue.use(Popup)`,
				htmlCode2: `<gr-popup v-model="show">内容</gr-popup>`,
				jsCode2: `export default {
	data() {
		return {
			show: false
		}
	}
}`,
				htmlCode3: `<gr-popup v-model="show" position="bottom">从下方弹出</gr-popup>`,
				htmlCode4: `<gr-popup v-model="show" round >内容</gr-popup>`,
				propertiesExplain1: [
					{
						attrName: 'v-model',
						introduce: `控制弹出层是否显示`,
						type: 'Boolean',
						optionValues: 'true / false',
						defaultValue: 'false'
					},
					{
						attrName: 'position',
						introduce: `弹出层的位置`,
						type: 'String',
						optionValues: 'top/bottom/left/right',
						defaultValue: 'bottom'
					},
					{
						attrName: 'round',
						introduce: `是否为圆角`,
						type: 'Boolean',
						optionValues: 'true / false',
						defaultValue: 'false'
					}
				],
				propertiesExplain2: [
					{
						attrName: 'over-click',
						introduce: `遮罩层的点击事件`,
						param: '----'
					}
				]
			}
		},
		mounted() {
			let ele = this.$refs.refCellPhone
			this.$refs.refContainer.addEventListener('scroll', (e)=> {
				ele.style.top = e.target.scrollTop + 'px';
			})
		}
	}
</script>

<style>
</style>
